package com.doit.mxdx;

public class Student {

    private String name;
    private int age;

    public Student() {
    }

    public Student(String name, int age){
        this.name=name;
        this.age=age;
    }

    @Override
    public String toString(){
        return "Student{name=‘"+name+"’, age="+age+"}";
    }

    //重写equals方法，按照对象的属性值进行比较
    @Override
    public boolean equals(Object o) {
        if (getClass() != o.getClass()) {
            return false;
        }else{
            //将o向下转换成Student类型
            Student student = (Student) o;
            if (age == student.age && name.equals(student.name)) {
                return true;
            }else {
                return false;
            }
        }
    }
}
